//
//  TopListTableViewCell.m
//  艾听歌
//
//  Created by dllo on 16/5/16.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "TopListTableViewCell.h"
#import "TopListCollectionViewCell.h"

#define TOPCELL @"topcell"

@interface TopListTableViewCell ()<UICollectionViewDataSource,UICollectionViewDelegate>
@property (nonatomic, strong) UICollectionView *TopListCollection;
@property (nonatomic, strong) UICollectionViewFlowLayout *TopFlowLayout;


@end



@implementation TopListTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createTopCollectionView];
    }
    return self;
}

- (void)createTopCollectionView
{
    self.TopFlowLayout = [[UICollectionViewFlowLayout alloc] init];
    self.TopFlowLayout.itemSize = CGSizeMake(self.contentView.frame.size.width / 3, self.contentView.frame.size.height - 10);
    
    self.TopFlowLayout.minimumInteritemSpacing = 0.5;
    
    self.TopListCollection = [[UICollectionView alloc] initWithFrame:self.contentView.bounds collectionViewLayout:self.TopFlowLayout];
    self.TopListCollection.delegate = self;
    self.TopListCollection.dataSource = self;
    [self.contentView addSubview:self.TopListCollection];
//    self.TopListCollection.backgroundColor = [UIColor clearColor];
    self.TopListCollection.dk_backgroundColorPicker = DKColorPickerWithRGB(0xffffff, 0x9C9C9C);
    [self.TopListCollection registerClass:[TopListCollectionViewCell class] forCellWithReuseIdentifier:TOPCELL];
    
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    self.TopListCollection.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height);
    self.TopFlowLayout.itemSize = CGSizeMake(self.contentView.frame.size.width / 3 - 2, self.contentView.frame.size.height);
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 3;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    TopListCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:TOPCELL forIndexPath:indexPath];
    

    cell.dk_backgroundColorPicker = DKColorPickerWithRGB(0xffffff, 0x9C9C9C);
    
    return cell;
}




- (void)setNewMusicModel:(MusicModel *)NewMusicModel
{
    _NewMusicModel = NewMusicModel;
    self.data = [NSMutableArray arrayWithArray:_NewMusicModel.data];
    [self.TopListCollection reloadData];
}














- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
